package cn.iocoder.yudao.module.system.controller.admin.gugu.vo.subjectselection;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.AssertTrue;
import java.util.List;

/**
 * 选科功能请求 VO
 */
@Schema(description = "选科功能请求参数")
@Data
public class SubjectSelectionReqVO {

    @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "安徽")
    @NotEmpty(message = "省份名称不能为空")
    private String province;

    @Schema(description = "年份", requiredMode = Schema.RequiredMode.REQUIRED, example = "2027")
    @NotNull(message = "年份不能为空")
    private Integer year;

    @Schema(description = "选择的专业大类列表",
            example = "[\"哲学类\", \"经济学类\", \"财政学类\", \"金融学类\"]")
    private List<String> selectedMajorCategories;

    @Schema(description = "选择的学校列表",
            example = "[\"北京大学\", \"清华大学\", \"复旦大学\"]")
    private List<String> selectedSchools;

    @Schema(description = "计算类型：category-按专业大类，school-按学校",
            requiredMode = Schema.RequiredMode.REQUIRED, example = "category")
    @NotEmpty(message = "计算类型不能为空")
    private String calculationType = "category";

    @Schema(description = "教育级别", example = "本科")
    private String educationLevel = "本科";

    @Schema(description = "文理综合类别", example = "理科")
    private String type;

    /**
     * 验证选择的数据是否有效
     */
    @AssertTrue(message = "根据计算类型，必须选择对应的专业大类或学校")
    public boolean isValidSelection() {
        if ("category".equals(calculationType)) {
            return selectedMajorCategories != null && !selectedMajorCategories.isEmpty();
        } else if ("school".equals(calculationType)) {
            return selectedSchools != null && !selectedSchools.isEmpty();
        }
        return false;
    }
}
